package com.supreme.businessserver.utils.datasource;

import com.alibaba.druid.pool.DruidDataSource;

public class DockerDatasource implements IDatasource {

    private final IDatasource datasource;
    private String proxyName = "default";

    public DockerDatasource(IDatasource datasource, String proxyName) {
        this.datasource = datasource;
        this.proxyName = proxyName;
    }

    @Override
    public IDatasource setDriverClassName(String driverClassName) {
        return this;
    }

    @Override
    public IDatasource setUrl(String host, int port, String dbName) {
        if (this.proxyName.equals("docker")) {
            this.datasource.setUrl(host, port, dbName);
        }
        return this;
    }

    @Override
    public IDatasource setUsername(String username) {
        return this;
    }

    @Override
    public IDatasource setPassword(String password) {
        return this;
    }

    @Override
    public DruidDataSource getDatasource() {
        return datasource.getDatasource();
    }
}
